package com.eastfair.auth.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author ligang
 * @date 2023-04-24
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "OrganizationVestTypeEnum", description = "组织类型归属#{P:项目;R:资源;E:展会;-枚举")
public enum OrganizationVestTypeEnum implements BaseEnum {

    /**
     * P="项目"
     */
    P("项目"),
    /**
     * R="资源"
     */
    R("资源"),
    /**
     * E="展会"
     */
    E("展会"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static OrganizationVestTypeEnum match(String val, OrganizationVestTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static OrganizationVestTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(OrganizationVestTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "P,R,E", example = "P")
    public String getCode() {
        return this.name();
    }

}
